package com.dongdong.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdong.mapper.TbOrderMapper;
import com.dongdong.mapper.TbPayLogMapper;
import com.dongdong.pojo.TbOrder;
import com.dongdong.pojo.TbPayLog;
import com.dongdong.service.PayLogService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Deacription TODO
 * @Author Lenovo
 * @Date 2020/12/24 10:10
 * @Version 1.0
 **/
@Service
@Component
public class PayLogServiceImpl implements PayLogService {

    @Resource
    private TbPayLogMapper payLogMapper;
    @Resource
    private TbOrderMapper orderMapper;

    @Override
    public void addPay(TbPayLog payLog) {
        System.out.println("进入方法");
        //根据payLogid查询Order表中的id
        List<TbOrder> orderList = orderMapper.selectByPayOrder(Long.parseLong(payLog.getOutTradeNo()));
        String str = "";
        for (TbOrder tbOrder : orderList) {
            str += tbOrder.getOrderId()+",";
        }
        payLog.setOrderList(str);
        System.out.println("payLog"+payLog);
        int count = payLogMapper.insertSelective(payLog);
        System.out.println("count"+count);
    }

    @Override
    public TbPayLog selectByOutTradeNo(String messageBody) {
        return payLogMapper.selectByOutTradeNo(messageBody);
    }
}

